package com.digital.smartgrow.controller.business;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.dto.business.UpJobLogPageDTO;
import com.digital.smartgrow.entity.business.UpJobLog;
import com.digital.smartgrow.service.business.UpJobLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 职评明细表 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-13
 */
@Api(tags = "职评明细表")
@RestController
@RequestMapping("${context.prefix}/business/upJobLog")
public class UpJobLogController {

    @Autowired
    private UpJobLogService upJobLogService;
    @ApiOperation(value = "职评明细表-分页关键字查询")
    @PostMapping("/listByKeyword")
    public Object getListByPage(
            @RequestParam(required = false,defaultValue = "1")Integer pageNum,
            @RequestParam(required = false,defaultValue = "15")Integer pageSize ,
            @RequestParam(required = false)String keyword,
            @RequestParam(required = false)String upLevel,
            @RequestParam(required = false)Integer status){
        return upJobLogService.getListByPage(pageNum,pageSize,keyword,upLevel,status);
    }
    @ApiOperation(value = "审核详情")
    @GetMapping("/checkInfo/{id}")
    public Object checkInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return upJobLogService.checkInfo(id);
    }
    @ApiOperation(value = "审核监控-根据学院统计")
    @GetMapping("/faculty")
    public Object getCountByFaculty(){
        return upJobLogService.getCountByFaculty();
    }

//@RequestParam(required = false,defaultValue = "10") int pageSize
//    @ApiOperation(value = "职评明细表-分页查询")
//    @PostMapping("/list")
    public Object getListByPage(@RequestBody UpJobLogPageDTO upJobLogPageDTO){
        return upJobLogService.getListByPage(upJobLogPageDTO);
    }

    @ApiOperation(value = "职评明细表-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return upJobLogService.getInfo(id);
    }

//    @ApiOperation(value = "职评明细表-删除")
//    @DeleteMapping("/{id}")
    public Object removeById(@PathVariable Integer id){
      if (id == null) return Result.fail("id不能为空");
      return upJobLogService.removeById(id);
    }
//    @ApiOperation(value = "职评明细表-新增")
//    @PostMapping()
    public Object add( @RequestBody UpJobLog upJobLog){
       return upJobLogService.save(upJobLog);
    }

//    @ApiOperation(value = "职评明细表-编辑")
//    @PutMapping()
    public Object edit(@RequestBody UpJobLog upJobLog){
    if (upJobLog==null||upJobLog.getId() == null)
       return Result.fail("id不能为空");
       return upJobLogService.updateById(upJobLog);
    }
}
